import { axiosMock, delayFn, randArrItem } from '@/services/axiosMock'
import { IWaybillInfo } from './interface'

axiosMock('default', mock => {
  // 获取运单基础信息
  mock.onPost(`/tmsapi/track_waybill/waybillInfo`).reply(
    delayFn<IWaybillInfo>(0, () => {
      const currentLogisticsNode = randArrItem([0, 1, 2, 3, 4, 5, 6])
      const logisticsNodeEnList = [
        'Handling',
        'Exporting',
        'In Transit',
        'Importing',
        'Transporting',
        'Out For Delivery',
        'Delivered',
      ]
      return {
        success: true,
        data: {
          abnormalStatus: randArrItem([-1, -1, 0, 0, 1], 0.1),
          deliverDate: randArrItem([`2023-12-11`, `2024-12-11`], 0.1),
          age: randArrItem(['12', '13'], 0.1),
          currentLogisticsNode,
          currentLogisticsNodeEn: logisticsNodeEnList[currentLogisticsNode],
          logisticsNodeList: [0, 1, 2, 3, 4, 5, 6],
          logisticsNodeEnList,
          archiveFlag: currentLogisticsNode === 6 ? randArrItem([0, 1]) : 0,
        },
      }
    }),
  )
})
